﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Commandparser.Common;

namespace Commandparser.Types
{
    class Converter : Method
    {

        public override IPropertyObject Parse(string content)
        {
            var returns = new Converter();
            Function f = ToFunction(content);

            if(f.Name == "int")
            {
                returns.Value = new @integer().Parse(f.Params[0]);
            }
            else if (f.Name == "string")
            {
                returns.Value = new @string().Parse(f.Params[0]);
            }
            else if (f.Name == "array")
            {
                returns.Value = new @integer().Parse(f.Params[0]);
            }


            return returns;
        }

        public override bool IsType(string content)
        {
            if (isFunction(content))
            {
                if (ToFunction(content).Name == "int")
                {
                    return true;
                }
                else if (ToFunction(content).Name == "string")
                {
                    return true;
                }
                else if (ToFunction(content).Name == "array")
                {
                    return true;
                }
            }
           
            return base.IsType(content);
        }

    }
}
